<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/drag.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .box {
            width: 200px;
            height: 200px;
            background-color: #6ff;
            position: absolute;
            left: 100px;
            top: 100px;
        }
    </style>
</head>

<body>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
</body>
<script>
    

    var boxList = document.getElementsByClassName("box");
    for (var i = 0; i < boxList.length; i++) {
        var box = boxList[i];

        // new DragEle() 调用构造函数 => 此时构造函数及其原型对象上的方法已经挂载完毕 => 可以在构造函数内容通过实例对象调用 init 
        var res = new DragEle(box);
        console.log(res);
        // 手动调用
        // res.randColor();
        // res.dragStart();
        // res.init();

    }

 








</script>

</html>